﻿using System;
using System.Collections.Generic;

namespace Anderson.PluginFramework
{
    public interface IServiceBus
    {
        /// <summary>
        /// 对于单例的服务对象，可以传入serviceInstance
        /// 对于非单例的服务对象，可不传入serviceInstance，使用含bool createNewInstance参数的GetService方法
        /// </summary>
        void RegisterService(IPlugin owner, Type serviceType, object serviceInstance);        
        void UnRegisterService(IPlugin owner, Type serviceType, object serviceInstance);

        /// <summary>
        /// 得到新的服务实例，服务使用者自行处理新创建实例的销毁
        /// </summary>
        object GetService(IPlugin leaseholder, Type serviceType, bool createNewInstance);

        void UnGetService(IPlugin leaseholder, Type serviceType);

        IDictionary<string, ServiceReference> DictAllService { get; }
    }
}